Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #824

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Solution #824

wants to merge 2 commits into from

Conversation

eLQeR
Copy link

@eLQeR eLQeR commented Oct 26, 2023

No description provided.

app/main.py Outdated
Comment on lines 17 to 29
for index1 in range(len(person_list)):
if "wife" in people[index1]:
if people[index1]["wife"] is not None:
for index2 in range(len(people)):
if people[index1]["wife"] == people[index2]["name"]:
person_list[index1].wife = person_list[index2]

elif "husband" in people[index1]:
if people[index1]["husband"] is not None:
for index2 in range(len(people)):
if people[index1]["husband"] == people[index2]["name"]:
person_list[index1].husband = person_list[index2]
return person_list

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So hard realization...... First of all why do you iterate through index? Also, why do you use loop into loop?
You have Person.people dict use it and only one loop here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use the first loop to add attributes to each person and the second to find husband/wife for him, I don't know how to make it by one loop

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use index because it is the same in the dict and in the list or person and it is easy to iterate so -__-

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont answer I got you )

Copy link

@YukihiroSM YukihiroSM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants